import Vue from "vue";
import dayjs from "dayjs";

Vue.prototype.getWorkTime = function(time){
    let hour1 = Number(time.slice(0,2))
    let minute1 = Number(time.slice(2,4))
    let hour2 = Number(time.slice(4,6))
    let minute2 = Number(time.slice(6,8))
    let time1 = Vue.prototype.getMinuteSinceDay(hour1, minute1)
    let time2 = Vue.prototype.getMinuteSinceDay(hour2, minute2)

    let minusMinute = 0

    if(time1 <= 8 * 60 + 30){
        time1 = 8 * 60 + 30
    }
    if(time1 <= 12 * 60 + 30 && time2 >= 14 * 60){
        minusMinute += 90
    }
    if(time2 >= 18 * 60 &&  time2 < 18 * 60 + 30){
        time2 = 18 * 60
    }
    if(time2 >= 18 * 60 + 30){
        minusMinute += 30
    }
    return time2 - time1 - minusMinute
}

Vue.prototype.getMinuteSinceDay = function(hour, minute){
    return hour * 60 + minute
}